import java.util.ArrayList;


public class Customer {
	private String name, ssn, address, zipcode, city;
	private ArrayList<Account> accounts;
	
	public Customer(String name, String ssn, String address, String zipcode, String city){
		this.name = name;
		this.ssn = ssn;
		this.address = address;
		this.zipcode = zipcode;
		this.city = city;
		accounts = new ArrayList<>();
	}
	
	public Account createAccount(String accountName, double interest) {
		int id = accounts.size()+1;
		Account a = new Account(id, accountName, interest);
		accounts.add(a);
		return a;
	}
	
	public void deleteAccount(int id) {
		accounts.remove(findAccount(id));
		System.out.println("Account: "+  id + " deleted");
	}
	
	public void depositToAccount(double deposite, int id) {
		findAccount(id).deposit(deposite);
	}
	
	public void withdrawFromAccount(double withdrawel, int id) {
		findAccount(id).withdraw(withdrawel);
	}
	
	public boolean setInterestForAccount(int id, double interest) {
		if(findAccount(id) != null) {
			setInterestForAccount(id, interest);
			return true;
		} else {
			return false;
		}
	}
	
	public Account findAccount(int id) {
		int index = 0;
		boolean found = false;
		while(index < accounts.size() && !found == true) {
			if(accounts.get(index).getId() == id) {
				found = true;
				return accounts.get(index); 
			}
			index++;
		}
		if(found == false) {
		}
		return null;
	}
	
	public void addInterest() {
		for(Account a : accounts) {
			a.addInterest();
		}
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSsn() {
		return ssn;
	}

	public void setSsn(String ssn) {
		this.ssn = ssn;
	}

	public ArrayList<Account> getAccounts() {
		return accounts;
	}

	public void setAccounts(ArrayList<Account> accounts) {
		this.accounts = accounts;
	}

	
	public String getAddress() {
		return address;
	}

	
	public void setAddress(String address) {
		this.address = address;
	}

	public String getZipcode() {
		return zipcode;
	}

	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}
	
	

	
}
